package j250215;

public class Main {
	public static void main(String[] args) {
		String s="croakcroak";
		char[] ss= s.toCharArray();
		int[] ints=new int[200];
		for(int i=0;i<ss.length;i++) {
			if(ss[i]=='c') {
				if(ints['k']==0) ints['c']++;
				else {
					ints['c']++;
					ints['k']--;
				}
			}
			if(ss[i]=='r') {
				if(ints['c']==0) return;
				else {
					ints['r']++;
					ints['c']--;
				}
			}
			if(ss[i]=='o') {
				if(ints['r']==0) return;
				else {
					ints['o']++;
					ints['r']--;
				}
			}
			if(ss[i]=='a') {
				if(ints['o']==0) return;
				else {
					ints['a']++;
					ints['o']--;
				}
			}
			if(ss[i]=='k') {
				if(ints['a']==0) return;
				else {
					ints['k']++;
					ints['a']--;
				}
			}
		}
		int sum=ints['c']+ints['r']+ints['o']+ints['a']+ints['k'];
		int c=ints['c'];
		int r=ints['r'];
		int o=ints['o'];
		int a=ints['a'];
		int k=ints['k'];
		if(sum-ints['k']>0) System.out.println(-1);
		
		else System.out.println(ints['k']==0?-1:ints['k']);
	}
	public static void main2(String[] args) {
		String s="11";
		s="111";
		System.out.println(s);
	}
	public static void main1(String[] args) {
		String s="abcdefghigklmnop";
		int numRows=4;
		char[] ss=s.toCharArray();
        String ret="";
        if(numRows==1) {
        	System.out.println(s);
        	System.exit(0);
        }
        int d=2*numRows-2;
        for(int i=0;i<numRows;i++){
            if(i==0||i==numRows-1){
            int n=0;
            while(i+n*d<s.length()){
                ret+=ss[i+n*d];
                n++;
            }
        }
        else{
            for(int m=i,n=d-m;m<ss.length||n<ss.length;m+=d,n+=d){
                if(m<ss.length) ret+=ss[m];
                if(n<ss.length) ret+=ss[n];
            }
        }
        }
        System.out.println(ret);
	}
}
